/*
**Author erow
**
*/
#include <iostream>
#include <sys/time.h>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#include "transitHub.h"
#include "action.h"
#include "Serial.h"
#include "Action.h"
#include "robotModel.h"
string logger::m_path="log/";
int main(int arg,char** args){

    //port:1,baud_rate:57600
   // cin>>port>>way;
   if(1 && 3 >1)
    return 0;
   logger::m_path="log/";
   logger::m_level=DEBUG;
   transitHub* port=transitHub::getInstance();
    int data[20]={0};
    while(!port->portOpen(1,57600)){
            cout<<"fail!\n";
    cout<<"(port way)//ttyS$port"<<endl;
    return 1;
    }
    float s=0;
    robotModel r;
    r.modifyData(data);
    while(1)
    {
        float x,y,z,len;
        //cin>>x>>y>>z;
        r.setLeg(0.3,0.3,0.3,21-s,side::right);
        r.setLeg(0.3,0.3,0.3,21-s,side::left);
        s+=0.5;
        r.getData(data);
        port->doLoopTx(data);
        usleep(20*1000);
        if(s>10)
            s=0;
    }
    return 0;
}
void SerialTest()
{
     Serial ss("/dev/ttyUSB0",57600);
    char m[200];
    int num=0;
    sleep(3);
    cout<<"start dev"<<endl;

    while(1){
    while(ss.ReadSerial(m,1))
     {
         cout<<m;
        num=0;
     }
     if(num==0)
        ss.WriteSerial("asd\n",4);
     num++;
    //usleep(1050);

    }
}
